package com.etboot.modules.activiti.serviceimpl;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.etboot.modules.activiti.dao.mapper.ActModelMapper;
import com.etboot.modules.activiti.entity.ActModel;
import com.etboot.modules.activiti.service.ActModelService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;


/**
 * 模型管理接口实现
 * @author xboot
 */
@Slf4j
@Service
@Transactional
public class ActModelServiceImpl extends ServiceImpl<ActModelMapper,ActModel> implements ActModelService {
    @Autowired
    private ActModelMapper actModelMapper;

    @Override
    public Page<ActModel> findByCondition(ActModel actModel, Page pageable) {
        QueryWrapper<ActModel> qw = new QueryWrapper<>();
        if(StrUtil.isNotBlank(actModel.getName())){
            qw.like("name",actModel.getName());
        }

        if(StrUtil.isNotBlank(actModel.getModelKey())){
            qw.like("model_key",actModel.getModelKey());
        }

        return actModelMapper.selectPage(pageable,qw);
    }
}